#include <iostream>
using namespace std;

void quickSort(int arr[], int left, int right) {
    if(left < right) {
        int i = left;
        int j = right;
        int m = arr[(left + right) / 2];
        while(i <= j) {
            while(arr[i] < m) i++;
            while(arr[j] > m) j--;
            if(i <= j) {
                int temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
                i++;
                j--;
            }
        }
        quickSort(arr, left, j);
        quickSort(arr, i, right);
    }
}

int main(){
	int arr[] = {10, 7, 8, 9, 1, 5};
	int n = sizeof(arr)/sizeof(arr[0]);
 	quickSort(arr, 0, n-1);
 	for(int i=0; i<n; i++){
   		printf("%d ", arr[i]);
 	}
 	return 0;
}
